#include<iostream>
#include<queue>
using namespace std;
int n, k, m;
queue<int>q;
int main()
{
	cin >> n >> k >> m;
	for (int i = 0, j = k; i < n; i ++,j ++) {
		if (j == n) {
			j = 0;
			q.push(j);
		}
		else {
			q.push(j);
		}
	}
	int cnt = 0;
	while (q.size() > 1) {
		int t = q.front();
		q.pop();
		cnt++;
		if (cnt % m) {
			q.push(t);
		}
	}
	cout << q.front() << endl;
	return 0;
}